#include "real_adaboost.h"
#include <math.h>

double real_adaboost::get_alpha(double * y, double * p, double * d, int l) {
	double error = get_error(y, p, d, l);
	double alpha = 0.5 * log((1+error)/(1-error));
	return alpha;
}

string real_adaboost::get_type() {
	return "real_adaboost";
}

double real_adaboost::get_error(double * y, double * p, double * d, int l) {
	double error = 0;
	for(int i = 0; i < l; i++) {
		double h = get_h(p[i]);
		error += d[i] * y[i] * h;
	}
	return error;
}

double real_adaboost::get_h(double p) {
	return 2 * p - 1;
}